package com.pearl.jacksonspringboot.demo.instantiator;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.pearl.jacksonspringboot.demo.custom.User;

/**
 * @author TD
 * @version 1.0
 * @date 2024/4/12
 */
public class Test {

    public static void main(String[] args) throws JsonProcessingException {

        ObjectMapper objectMapper = new ObjectMapper();

        User user = new User();
        user.setId(1699657986705854464L);
        user.setUsername("zhaolusi");

        // 序列化
        objectMapper.setHandlerInstantiator(new MyHandlerInstantiator());
        String userVoJson = objectMapper.writeValueAsString(user);
        System.out.println(userVoJson);
    }
}
